// 删除服务器文件
const request = require('request');
const {
    LINK,
    createSign
} = require('./util');


function deleteFile(fileName) {
    const url = `/aiimage/${fileName}`;
    const date = new Date().toUTCString();
    const Authorization = createSign('DELETE', '', url, date);

    const headers = {
      Authorization,
      Date: date,
    };

    request({
        url: `${LINK}${url}`,
        headers,
        method: 'DELETE'
    }, (error, response) => {
        if (error) {
            console.error('delete file error: ', error);
            return;
        }

        console.log('delete file success: ', fileName);
    });
}


module.exports = deleteFile;